import request from '@/utils/request'
import moment from 'moment'
const formOfEmploymentMapping = new Map([
  ['1', '非正式'],
  [1, '正式']
])
export function getEmployeesList(params) {
  return request({
    url: '/sys/user',
    params
  })
    .then(res => ({
      rows: res.data.data.rows.map((item, i) => ({
        ...item,
        index: (params.page - 1) * (params.size) + i + 1,
        formOfEmployment: formOfEmploymentMapping.get(item.formOfEmployment),
        timeOfEntry: moment(item.timeOfEntry).format('YYYY-MM-DD')
      })),
      total: res.data.data.total

    }))
    .catch(() => [])
}

// 获取员工简单列表
export function getEmployee() {
  return request({
    url: '/sys/user/simple',
  })
    .then(res => res.data.data)
    .catch(() => ({}))
}
